package cn.tianya.irock.bll;

import java.sql.Date;
import java.util.List;

import cn.tianya.irock.core.DateTime;
import cn.tianya.irock.data.dalfactory.DataAccess;
import cn.tianya.irock.data.idal.ILogDataProvider;
import cn.tianya.irock.data.model.Log;
import cn.tianya.irock.enums.LogType;

public class Logs {
	private static ILogDataProvider provider;

    static {
        provider = DataAccess.createLogDataProvider();
    }
    
	public static void add(String desc) {
		add(desc, LogType.Info);
	}
	
	public static void add(Object refer) {
		add("", LogType.Info);
	}
	
	public static void add(Object refer, String desc) {
		add(desc, LogType.Info, refer);
	}
	
	public static void add(Object refer, int type) {
		add("", type, refer);
	}
	
	public static void add(String desc, int type) {
		add(desc, type, null);
	}
	
	public static void add(String desc, int type, Object refer) {
		Log log = new Log();
		
		log.setDescription(desc);
		log.setType(type);
		log.setRefer(refer);
		log.setDateCreated(new Date(DateTime.now().getTime()));
		log.setUserId(Users.getUser().getUserId());
		
		add(log);
	}
	
	public static void add(Log log) {
		provider.add(log);
	}
	
	public static List<Log> getLogs(int pageIndex, int pageSize) {
		List<Log> logs = null;
		
		return logs;
	}
}
